package com.theaf.basemodule.service.impl.core;

import com.alibaba.dubbo.config.annotation.Service;
import com.theaf.basemodule.common.api.PositionService;
import com.theaf.basemodule.common.dto.PositionDTO;
import com.theaf.core.api.PositionComService;
import com.theaf.core.api.model.Position;
import org.dozer.Mapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author:songwenke
 * @Description:岗位外部服务
 * @Date:create in 10:56 2018/3/6
 * @Modified By:
 **/
@Service
public class PositionServiceDubboImpl implements PositionComService {
    @Autowired
    private PositionService positionService;

    @Autowired
    private Mapper mapper;

    @Override
    public Position findById(Long id) {
        PositionDTO positionDTO = positionService.findById(id);
        return mapper.map(positionDTO,Position.class);
    }

    @Override
    public List<Position> findByOrganType(String organType) {
        return positionService.findByOrganType(organType).parallelStream().map(
                n->mapper.map(n,Position.class)).collect(Collectors.toList());
    }
}
